var Peekr = function () {
    function e(e, t, r) {
        var o = w + e;
        window[o] = r;
        var i = document.createElement("script");
        i.src = "http://api.thepeekr.com/data?callback=" + o + "&url=" + encodeURIComponent(t), document.body.appendChild(i)
    }

    function t(e, t, r) {
        v && document.getElementsByTagName("body")[0].removeChild(v), v = o(e, t, r)
    }

    function r() {
        v && (document.getElementsByTagName("body")[0].removeChild(v), v = null)
    }

    function o(e, t, r) {
        var o = i(t),
            n = _(o, e, r);
        return n
    }

    function i(e) {
        var t = "";
        return e.image && e.title && e.description ? t = p(e) : e.image && e.title ? t = a(e) : e.title && e.description ? t = d(e) : e.title && (t = l(e)), t
    }

    function n(e) {
        return y ? "background-image: url('" + b(e) + "');" : "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + b(e) + "'," + "sizingMethod='scale');" + '-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(' + "src='" + b(e) + "'," + "sizingMethod='scale');\""
    }

    function p(e) {
        var t = '<div id="_cbrmurl_container" class="_cbrmurl_container _cbrmurl_container_full">';
        return t += '<div class="_cbrmurl_image_container">', t += '<div class="_cbrmurl_image"', t += 'style="' + n(e) + '"></div></div>', t += '<div class="_cbrmurl_title">' + e.title + "</div>", t += '<div class="_cbrmurl_url">' + e.url + "</div>", t += '<div class="_cbrmurl_description">' + e.description + "</div>"
    }

    function a(e) {
        var t = '<div id="_cbrmurl_container" class="_cbrmurl_container _cbrmurl_container_image_title">';
        return t += '<div class="_cbrmurl_image_container">', t += '<div class="_cbrmurl_image"', t += 'style="' + n(e) + '"></div></div>', t += '<div class="_cbrmurl_title">' + e.title + "</div>", t += '<div class="_cbrmurl_url">' + e.url + "</div>"
    }

    function l(e) {
        var t = '<div id="_cbrmurl_container" class="_cbrmurl_container _cbrmurl_container_title">';
        return t += '<div class="_cbrmurl_title">' + e.title + "</div>", t += '<div class="_cbrmurl_url">' + e.url + "</div>"
    }

    function d(e) {
        var t = '<div id="_cbrmurl_container" class="_cbrmurl_container _cbrmurl_container_title_desc">';
        return t += '<div class="_cbrmurl_title">' + e.title + "</div>", t += '<div class="_cbrmurl_url">' + e.url + "</div>", t += '<div class="_cbrmurl_description">' + e.description + "</div>"
    }

    function _(e, t, r) {
        var o = s("_cbrmurl");
        return o.style.visibility = "hidden", o.style.opacity = 0, o.innerHTML = e, document.getElementsByTagName("body")[0].appendChild(o), c(o, t, r), o.style.visibility = "", o.style.opacity = 1, o
    }

    function c(e, t, r) {
        var o = f(e, t, r),
            i = e.getElementsByTagName("div")[0],
            n = g(t),
            p = r && r.clientX ? r.clientX - 30 : n.left;
        "bottom_left" == o ? (e.style.left = p + "px", e.style.top = n.top + 30 + "px", y && (i.className += " _cbrmurl_arrow_bottom_left")) : "bottom_right" == o ? (e.style.left = p - e.clientWidth + 60 + "px", e.style.top = n.top + 30 + "px", y && (i.className += " _cbrmurl_arrow_bottom_right")) : "top_right" == o ? (e.style.left = p - e.clientWidth + 60 + "px", e.style.top = n.top - 12 - e.clientHeight + "px", y && (i.className += " _cbrmurl_arrow_top_right")) : (e.style.left = p + "px", e.style.top = n.top - 12 - e.clientHeight + "px", y && (i.className += " _peekr_arrow_top_left"))
    }

    function f(e, t, r) {
        var o = g(t),
            i = u(),
            n = r && r.clientX ? r.clientX - 30 : o.left,
            p = "top_";
        return 0 > o.top - 12 - e.clientHeight - 10 - i.scrollTop && (p = "bottom_"), p += n + e.clientWidth + 20 > document.documentElement.clientWidth ? "right" : "left"
    }

    function s(e, t) {
        var r = document.createElement("div");
        return r.setAttribute("class", e), t && (r.innerHTML = t), r
    }

    function b(e) {
        function t(e) {
            var t = document.createElement("a");
            return t.href = e.url, t.protocol + "//" + t.hostname
        }
        return e.image && 0 == e.image.indexOf("//") ? "http:" + e.image : e.image && 0 == e.image.indexOf("http") ? e.image : e.image ? t(e) + "/" + e.image : void 0
    }

    function g(e) {
        var t = e,
            r = 0,
            o = 0;
        if (document.getElementById || document.all) {
            do
                for (o += e.offsetLeft - e.scrollLeft, r += e.offsetTop - e.scrollTop, e = e.offsetParent, t = t.parentNode; t != e;) o -= t.scrollLeft, r -= t.scrollTop, t = t.parentNode; while (e.offsetParent)
        } else document.layers && (r += e.y, o += e.x);
        return {
            top: r,
            left: o
        }
    }

    function u() {
        var e = void 0 !== window.pageXOffset ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft,
            t = void 0 !== window.pageYOffset ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
        return {
            scrollTop: t,
            scrollLeft: e
        }
    }

    function h(e, t, r) {
        e.addEventListener ? e.addEventListener(t, r, !1) : e.attachEvent && e.attachEvent("on" + t, r)
    }
    var k = 0,
        m = {},
        x = {},
        v = null,
        w = "_peekr_callback_",
        y = !!window.atob,
        T = function (e) {
            var t = !1,
                o = function (r) {
                    t = !0;
                    var o = {
                        clientX: r.clientX,
                        clientY: r.clientY
                    };
                    setTimeout(function () {
                        t && E(e, o)
                    }, 200)
                },
                i = function () {
                    t = !1, setTimeout(function () {
                        t || r()
                    }, 200)
                };
            h(e, "mouseover", o), h(e, "mouseout", i)
        },
        E = function (r, o) {
            if (null == r.href) throw "Falta atributo href";
            var i = k++;
            x[r.href] ? t(r, x[r.href], o) : (m[i] = r, e(i, r.href, function (e) {
                x[r.href] = e, t(m[i], e, o)
            }))
        },
        z = function (t, r) {
            var o = k++;
            e(o, t, r)
        };
    return {
        dataHtml: i,
        attach: T,
        open: E,
        data: z
    }
}();
"undefined" != typeof jQuery && function (e) {
    e.fn.attachPeekr = function () {
        return this.each(function () {
            if (!e(this).attr("href")) throw "Falta atributo href";
            Peekr.attach(this)
        })
    }, e.fn.urlMetaData = function (t) {
        return this.each(function () {
            if (!e(this).attr("href")) throw "Falta atributo href";
            Peekr.data(e(this).attr("href"), t)
        })
    }
}(jQuery);